package com.derbysoft.synxisadapter.commons.repository.impl;

import com.derbysoft.core.utils.DateTimeUtils;
import com.derbysoft.synxisadapter.commons.model.Direction;
import com.derbysoft.synxisadapter.commons.model.OperationType;
import org.apache.commons.lang.StringUtils;

import java.util.Date;

/**
 * User: jason
 * Date: 2013-01-25
 */
public class TransactionLogCondition {
    private static final int ONE_WEEK = -7;
    private OperationType operationType;

    private Date after = DateTimeUtils.offsetDays(ONE_WEEK);
    private Date before = new Date();

    private Direction direction;

    private String keyWord;

    private Long timespan;

    private ErrorFilter errorFilter = ErrorFilter.ALL;

    public enum ErrorFilter {
        ALL,
        HAS_ERROR,
        NO_ERROR
    }


    public OperationType getOperationType() {
        return operationType;
    }

    public void setOperationType(OperationType operationType) {
        this.operationType = operationType;
    }

    public Date getAfter() {
        return after;
    }

    public void setAfter(Date after) {
        this.after = after;
    }

    public Date getBefore() {
        return before;
    }

    public void setBefore(Date before) {
        this.before = before;
    }

    public Direction getDirection() {
        return direction;
    }

    public void setDirection(Direction direction) {
        this.direction = direction;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = StringUtils.trimToNull(keyWord);
    }

    public Long getTimespan() {
        return timespan;
    }

    public void setTimespan(Long timespan) {
        this.timespan = timespan;
    }

    public ErrorFilter getErrorFilter() {
        return errorFilter;
    }

    public void setErrorFilter(ErrorFilter errorFilter) {
        this.errorFilter = errorFilter;
    }
}
